﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.3.46    放款信息主表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_LOAN_MAIN: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_LOAN_MAIN()
		{}
		#region Model
		private long _id;
		private long _proid;
		private long _conid;
		private string _applyno;
		private string _custname;
		private string _custno;
		private long _productid;
		private string _productname;
		private int _fieldproject;
		private string _loanno;
		private Nullable<DateTime> _signdate;
		private string _applyby;
		private string _applybyname;
		private Nullable<DateTime> _applydate;
		private int _busstype;
		private string _custname2;
		private string _corpaddr;
		private decimal _amt;
		private int _loanphase;
		private int _loanphasetype;
		private decimal _loanfeerate;
		private decimal _rate;
		private decimal _managerate;
		private long _mediatorid;
		private string _mediator;
		private string _mediatoraccount;
		private string _promanager;
		private string _riskmanager;
		private string _lender;
		private string _lendorcorp;
		private string _riskstep;
		private int _loanpayment;
		private string _specailremark;
		private Nullable<DateTime> _loandate;
		private Nullable<DateTime> _enddate;
		private decimal _reccharges;
		private int _isdeduction;
		private decimal _dedfees;
		private decimal _actamt;
		private string _checkby;
		private string _checkbyname;
		private Nullable<DateTime> _checkdate;
		private string _remark;
		private string _touser;
		private int _status;
		private int _loanstatus;
		private string _confirmby;
		private Nullable<DateTime> _confirmdate;
		private int _returnstatus;
		/// <summary>
		/// 记录ID唯一
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 立项申请记录IDTb_app_proinfo.id
		/// </summary>
		[DataMember]
		public long PROID
		{
			get{return _proid;}
			set{
				if ( _proid!= value)
				{
					 _proid = value;
					OnPropertyChanged("PROID");
				}
			}
		}
		/// <summary>
		/// 合同记录ID
		/// </summary>
		[DataMember]
		public long CONID
		{
			get{return _conid;}
			set{
				if ( _conid!= value)
				{
					 _conid = value;
					OnPropertyChanged("CONID");
				}
			}
		}
		/// <summary>
		/// 申请编号
		/// </summary>
		[DataMember]
		public string APPLYNO
		{
			get{return _applyno;}
			set{
				if ( _applyno!= value)
				{
					 _applyno = value;
					OnPropertyChanged("APPLYNO");
				}
			}
		}
		/// <summary>
		/// 客户名称
		/// </summary>
		[DataMember]
		public string CUSTNAME
		{
			get{return _custname;}
			set{
				if ( _custname!= value)
				{
					 _custname = value;
					OnPropertyChanged("CUSTNAME");
				}
			}
		}
		/// <summary>
		/// 证件号码
		/// </summary>
		[DataMember]
		public string CUSTNO
		{
			get{return _custno;}
			set{
				if ( _custno!= value)
				{
					 _custno = value;
					OnPropertyChanged("CUSTNO");
				}
			}
		}
		/// <summary>
		/// 贷款产品记录ID
		/// </summary>
		[DataMember]
		public long PRODUCTID
		{
			get{return _productid;}
			set{
				if ( _productid!= value)
				{
					 _productid = value;
					OnPropertyChanged("PRODUCTID");
				}
			}
		}
		/// <summary>
		/// 贷款产品名称
		/// </summary>
		[DataMember]
		public string PRODUCTNAME
		{
			get{return _productname;}
			set{
				if ( _productname!= value)
				{
					 _productname = value;
					OnPropertyChanged("PRODUCTNAME");
				}
			}
		}
		/// <summary>
		/// 是否外地项目0本地项目，1外地项目
		/// </summary>
		[DataMember]
		public int FIELDPROJECT
		{
			get{return _fieldproject;}
			set{
				if ( _fieldproject!= value)
				{
					 _fieldproject = value;
					OnPropertyChanged("FIELDPROJECT");
				}
			}
		}
		/// <summary>
		/// 贷款号
		/// </summary>
		[DataMember]
		public string LOANNO
		{
			get{return _loanno;}
			set{
				if ( _loanno!= value)
				{
					 _loanno = value;
					OnPropertyChanged("LOANNO");
				}
			}
		}
		/// <summary>
		/// 合同签订日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> SIGNDATE
		{
			get{return _signdate;}
			set{
				if ( _signdate!= value)
				{
					 _signdate = value;
					OnPropertyChanged("SIGNDATE");
				}
			}
		}
		/// <summary>
		/// 申请人
		/// </summary>
		[DataMember]
		public string APPLYBY
		{
			get{return _applyby;}
			set{
				if ( _applyby!= value)
				{
					 _applyby = value;
					OnPropertyChanged("APPLYBY");
				}
			}
		}
		/// <summary>
		/// 申请人姓名
		/// </summary>
		[DataMember]
		public string APPLYBYNAME
		{
			get{return _applybyname;}
			set{
				if ( _applybyname!= value)
				{
					 _applybyname = value;
					OnPropertyChanged("APPLYBYNAME");
				}
			}
		}
		/// <summary>
		/// 申请日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> APPLYDATE
		{
			get{return _applydate;}
			set{
				if ( _applydate!= value)
				{
					 _applydate = value;
					OnPropertyChanged("APPLYDATE");
				}
			}
		}
		/// <summary>
		/// 项目类别
		/// </summary>
		[DataMember]
		public int BUSSTYPE
		{
			get{return _busstype;}
			set{
				if ( _busstype!= value)
				{
					 _busstype = value;
					OnPropertyChanged("BUSSTYPE");
				}
			}
		}
		/// <summary>
		/// 借款方
		/// </summary>
		[DataMember]
		public string CUSTNAME2
		{
			get{return _custname2;}
			set{
				if ( _custname2!= value)
				{
					 _custname2 = value;
					OnPropertyChanged("CUSTNAME2");
				}
			}
		}
		/// <summary>
		/// 项目地址
		/// </summary>
		[DataMember]
		public string CORPADDR
		{
			get{return _corpaddr;}
			set{
				if ( _corpaddr!= value)
				{
					 _corpaddr = value;
					OnPropertyChanged("CORPADDR");
				}
			}
		}
		/// <summary>
		/// 贷款金额
		/// </summary>
		[DataMember]
		public decimal AMT
		{
			get{return _amt;}
			set{
				if ( _amt!= value)
				{
					 _amt = value;
					OnPropertyChanged("AMT");
				}
			}
		}
		/// <summary>
		/// 贷款期限0天，1月，默认为1
		/// </summary>
		[DataMember]
		public int LOANPHASE
		{
			get{return _loanphase;}
			set{
				if ( _loanphase!= value)
				{
					 _loanphase = value;
					OnPropertyChanged("LOANPHASE");
				}
			}
		}
		/// <summary>
		/// 贷款期限类型
		/// </summary>
		[DataMember]
		public int LOANPHASETYPE
		{
			get{return _loanphasetype;}
			set{
				if ( _loanphasetype!= value)
				{
					 _loanphasetype = value;
					OnPropertyChanged("LOANPHASETYPE");
				}
			}
		}
		/// <summary>
		/// 手续费率
		/// </summary>
		[DataMember]
		public decimal LOANFEERATE
		{
			get{return _loanfeerate;}
			set{
				if ( _loanfeerate!= value)
				{
					 _loanfeerate = value;
					OnPropertyChanged("LOANFEERATE");
				}
			}
		}
		/// <summary>
		/// 利率
		/// </summary>
		[DataMember]
		public decimal RATE
		{
			get{return _rate;}
			set{
				if ( _rate!= value)
				{
					 _rate = value;
					OnPropertyChanged("RATE");
				}
			}
		}
		/// <summary>
		/// 顾问费率
		/// </summary>
		[DataMember]
		public decimal MANAGERATE
		{
			get{return _managerate;}
			set{
				if ( _managerate!= value)
				{
					 _managerate = value;
					OnPropertyChanged("MANAGERATE");
				}
			}
		}
		/// <summary>
		/// 推介人记录ID
		/// </summary>
		[DataMember]
		public long MEDIATORID
		{
			get{return _mediatorid;}
			set{
				if ( _mediatorid!= value)
				{
					 _mediatorid = value;
					OnPropertyChanged("MEDIATORID");
				}
			}
		}
		/// <summary>
		/// 推介人
		/// </summary>
		[DataMember]
		public string MEDIATOR
		{
			get{return _mediator;}
			set{
				if ( _mediator!= value)
				{
					 _mediator = value;
					OnPropertyChanged("MEDIATOR");
				}
			}
		}
		/// <summary>
		/// 推介人账号银行和账号填写在一起
		/// </summary>
		[DataMember]
		public string MEDIATORACCOUNT
		{
			get{return _mediatoraccount;}
			set{
				if ( _mediatoraccount!= value)
				{
					 _mediatoraccount = value;
					OnPropertyChanged("MEDIATORACCOUNT");
				}
			}
		}
		/// <summary>
		/// 项目经理
		/// </summary>
		[DataMember]
		public string PROMANAGER
		{
			get{return _promanager;}
			set{
				if ( _promanager!= value)
				{
					 _promanager = value;
					OnPropertyChanged("PROMANAGER");
				}
			}
		}
		/// <summary>
		/// 风控经理
		/// </summary>
		[DataMember]
		public string RISKMANAGER
		{
			get{return _riskmanager;}
			set{
				if ( _riskmanager!= value)
				{
					 _riskmanager = value;
					OnPropertyChanged("RISKMANAGER");
				}
			}
		}
		/// <summary>
		/// 出借人
		/// </summary>
		[DataMember]
		public string LENDER
		{
			get{return _lender;}
			set{
				if ( _lender!= value)
				{
					 _lender = value;
					OnPropertyChanged("LENDER");
				}
			}
		}
		/// <summary>
		/// 顾问公司
		/// </summary>
		[DataMember]
		public string LENDORCORP
		{
			get{return _lendorcorp;}
			set{
				if ( _lendorcorp!= value)
				{
					 _lendorcorp = value;
					OnPropertyChanged("LENDORCORP");
				}
			}
		}
		/// <summary>
		/// 风控措施落实情况
		/// </summary>
		[DataMember]
		public string RISKSTEP
		{
			get{return _riskstep;}
			set{
				if ( _riskstep!= value)
				{
					 _riskstep = value;
					OnPropertyChanged("RISKSTEP");
				}
			}
		}
		/// <summary>
		/// 还款方式具体参考” 还款计息方式”文档
		/// </summary>
		[DataMember]
		public int LOANPAYMENT
		{
			get{return _loanpayment;}
			set{
				if ( _loanpayment!= value)
				{
					 _loanpayment = value;
					OnPropertyChanged("LOANPAYMENT");
				}
			}
		}
		/// <summary>
		/// 特别备注
		/// </summary>
		[DataMember]
		public string SPECAILREMARK
		{
			get{return _specailremark;}
			set{
				if ( _specailremark!= value)
				{
					 _specailremark = value;
					OnPropertyChanged("SPECAILREMARK");
				}
			}
		}
		/// <summary>
		/// 出款时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> LOANDATE
		{
			get{return _loandate;}
			set{
				if ( _loandate!= value)
				{
					 _loandate = value;
					OnPropertyChanged("LOANDATE");
				}
			}
		}
		/// <summary>
		/// 贷款到期日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> ENDDATE
		{
			get{return _enddate;}
			set{
				if ( _enddate!= value)
				{
					 _enddate = value;
					OnPropertyChanged("ENDDATE");
				}
			}
		}
		/// <summary>
		/// 已预收费用
		/// </summary>
		[DataMember]
		public decimal RECCHARGES
		{
			get{return _reccharges;}
			set{
				if ( _reccharges!= value)
				{
					 _reccharges = value;
					OnPropertyChanged("RECCHARGES");
				}
			}
		}
		/// <summary>
		/// 放款中抵扣手续费0否，1是
		/// </summary>
		[DataMember]
		public int ISDEDUCTION
		{
			get{return _isdeduction;}
			set{
				if ( _isdeduction!= value)
				{
					 _isdeduction = value;
					OnPropertyChanged("ISDEDUCTION");
				}
			}
		}
		/// <summary>
		/// 放款中抵扣费用
		/// </summary>
		[DataMember]
		public decimal DEDFEES
		{
			get{return _dedfees;}
			set{
				if ( _dedfees!= value)
				{
					 _dedfees = value;
					OnPropertyChanged("DEDFEES");
				}
			}
		}
		/// <summary>
		/// 实际放款额
		/// </summary>
		[DataMember]
		public decimal ACTAMT
		{
			get{return _actamt;}
			set{
				if ( _actamt!= value)
				{
					 _actamt = value;
					OnPropertyChanged("ACTAMT");
				}
			}
		}
		/// <summary>
		/// 财务复核人
		/// </summary>
		[DataMember]
		public string CHECKBY
		{
			get{return _checkby;}
			set{
				if ( _checkby!= value)
				{
					 _checkby = value;
					OnPropertyChanged("CHECKBY");
				}
			}
		}
		/// <summary>
		/// 财务复核人姓名
		/// </summary>
		[DataMember]
		public string CHECKBYNAME
		{
			get{return _checkbyname;}
			set{
				if ( _checkbyname!= value)
				{
					 _checkbyname = value;
					OnPropertyChanged("CHECKBYNAME");
				}
			}
		}
		/// <summary>
		/// 复核日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CHECKDATE
		{
			get{return _checkdate;}
			set{
				if ( _checkdate!= value)
				{
					 _checkdate = value;
					OnPropertyChanged("CHECKDATE");
				}
			}
		}
		/// <summary>
		/// 备注
		/// </summary>
		[DataMember]
		public string REMARK
		{
			get{return _remark;}
			set{
				if ( _remark!= value)
				{
					 _remark = value;
					OnPropertyChanged("REMARK");
				}
			}
		}
		/// <summary>
		/// 提交到
		/// </summary>
		[DataMember]
		public string TOUSER
		{
			get{return _touser;}
			set{
				if ( _touser!= value)
				{
					 _touser = value;
					OnPropertyChanged("TOUSER");
				}
			}
		}
		/// <summary>
		/// 状态0保存，1提交,2已确认，3已作废
		/// </summary>
		[DataMember]
		public int STATUS
		{
			get{return _status;}
			set{
				if ( _status!= value)
				{
					 _status = value;
					OnPropertyChanged("STATUS");
				}
			}
		}
		/// <summary>
		/// 放款状态0未确认放款，1已确认放款
		/// </summary>
		[DataMember]
		public int LOANSTATUS
		{
			get{return _loanstatus;}
			set{
				if ( _loanstatus!= value)
				{
					 _loanstatus = value;
					OnPropertyChanged("LOANSTATUS");
				}
			}
		}
		/// <summary>
		/// 确认人如果为作废则此数据项记录的是作废操作人
		/// </summary>
		[DataMember]
		public string CONFIRMBY
		{
			get{return _confirmby;}
			set{
				if ( _confirmby!= value)
				{
					 _confirmby = value;
					OnPropertyChanged("CONFIRMBY");
				}
			}
		}
		/// <summary>
		/// 确认时间如果为作废则此数据项记录的是作废操作时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CONFIRMDATE
		{
			get{return _confirmdate;}
			set{
				if ( _confirmdate!= value)
				{
					 _confirmdate = value;
					OnPropertyChanged("CONFIRMDATE");
				}
			}
		}
		/// <summary>
		/// 收回状态0未有收回，1部分收回，2自动结清，3手动结清
		/// </summary>
		[DataMember]
		public int RETURNSTATUS
		{
			get{return _returnstatus;}
			set{
				if ( _returnstatus!= value)
				{
					 _returnstatus = value;
					OnPropertyChanged("RETURNSTATUS");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

